/*******************************************************************
//  Constellation mapping 
//   16 QAM
//   0000 ->  1+j    0001 ->  1+3j    0010 ->  3+j    0011 ->  3+3j
//   0100 ->  1-j    0101 ->  1-3j    0110 ->  3-j    0111 ->  3-3j
//   1000 -> -1+j    1001 -> -1+3j    1010 -> -3+j    1011 -> -3+3j
//   1100 -> -1-j    1101 -> -j-3j    1110 -> -3-j    1111 -> -3-3j
//  Date : 04/11/2011
//  Jungmin Park
********************************************************************/

#include "constellation_mapping.h"

void constellation_mapping (char a, float *x, float *y)
{
	char mask = 0x0F;
	char temp = 0;
	
    temp = a & mask;
		
	switch( temp ) 
	{
       case 0:
		   *x = 1;  
		   *y = 1; 
		   break; 
	   case 1:
		   *x = 1;
		   *y = 3;
		   break;
	   case 2:
		   *x = 3;  
		   *y = 1; 
		   break; 
	   case 3:
		   *x = 3;
		   *y = 3;
		   break; 
       case 4:
		   *x = 1;  
		   *y = -1; 
		   break; 
	   case 5:
		   *x = 1;
		   *y = -3;
		   break;
	   case 6:
		   *x = 3;  
		   *y = -1; 
		   break; 
	   case 7:
		   *x = 3;
		   *y = -3;
		   break; 
       case 8:
		   *x = -1;  
		   *y = 1; 
		   break; 
	   case 9:
		   *x = -1;
		   *y = 3;
		   break;
	   case 10:
		   *x = -3;  
		   *y = 1; 
		   break; 
	   case 11:
		   *x = -3;
		   *y = 3;
		   break; 
       case 12:
		   *x = -1;  
		   *y = -1; 
		   break; 
	   case 13:
		   *x = -1;
		   *y = -3;
		   break;
	   case 14:
		   *x = -3;  
		   *y = -1; 
		   break; 
	   case 15:
		   *x = -3;
		   *y = -3;
		   break; 
	}
}


